<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>被测人管理</title>
<!-- 导入jquery核心类库 -->
<%@include file="../include/jqueryeasyui.jsp"%>

<script type="text/javascript">

$(function(){
	
	main();
	
});

	function main(){
 		initDatagrid();
		initBtn();
	}
	
	 
	
	function initDatagrid(){
		// 先将body隐藏，再显示，不会出现页面刷新效果
		$("body").css({visibility:"visible"});
		
		// 收派标准数据表格
		$('#grid').datagrid( {
			iconCls : 'icon-forward',
			fit : true,
			border : false,
			rownumbers : true,
			singleSelect:true,
            checkOnSelect:true,  
            selectOncheck:true,
			striped : true,
			toolbar : '#tb',
			url : "${pageContext.request.contextPath}/contract/page.contractStatus.ashx",

			columns : columns,
			pageList: [10,20],
			pagination:true,
			view:myview,
			emptyMsg:"<font size=5>暂无记录</font>"
			
		});
	}
	
	function initBtn(){
		
		$('#search').click(doSearch);
		 
	}
	
	

	
	function getQueryParams(queryParams) { 
		
		var contractserial = $('#contractserial').val();
		var cPName = $('#cPName').val();
  	     queryParams.cPIDSerial = contractserial;  
	     queryParams.cPName = cPName; 
	    
	     return queryParams;  
	   
	 }  
	
	 //增加查询参数，重新加载表格  
    function reloadgrid() {  
		 
   
        //查询参数直接添加在queryParams中      
        var queryParams = $('#grid').datagrid('options').queryParams;  
        getQueryParams(queryParams);  
        $('#grid').datagrid('options').queryParams = queryParams;  
       
        $("#grid").datagrid('load');  
    }  
	 
	function doSearch(){		
		reloadgrid();
	}
	
	 
	 

	
	 
	


	// 定义列
	var columns = [ [  {
		field : 'cPIDSerial',
		title : '项目编号',
		width : 200,
		
	},{
		field : 'cPName',
		title : '项目名称',
		width : 200,	
	},  {
		field : 'contractCustomerProgressRatio',
		title : '当前进度',
		width : 300,
		
	},  {
		field : 'cPIDContract',
		title : '操作',
		width : 300,
		formatter:formatterCaozuo
		
	} ] ];
	
	 
	
	function formatterCaozuo(value,row,index) {
		var cPIDSerial =  row.cPIDSerial;
   		return "<a href=# onclick=fenchangProgressRatio(\'"+cPIDSerial+"\')>查看该项目分场进度</a>"+"&nbsp;&nbsp;&nbsp;&nbsp;"; 
   		//return "fgfgfg"; 
	
	}
	
	function fenchangProgressRatio(cPIDSerial){
	    var parent$ = self.parent.$;      //找到父级DOM  
	    
    	var text =cPIDSerial+"分场进度";
        var url="page.fenchangstatus.ashx?cPIDSerial="+cPIDSerial;
		if (parent$("#tabs").tabs('exists', text)) {
			parent$('#tabs').tabs('select', text);
		} else {
			var content = '<div style="width:100%;height:100%;overflow:hidden;">'
					+ '<iframe src="'
					+ url
					+ '" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';

				parent$('#tabs').tabs('add', {
				title : text,
				content : content,
				closable : true
			});
		}
	}
 
	
	
 
	
 
	
 
 


		
		

	
	
	
	var myview = $.extend({},$.fn.datagrid.defaults.view,{
		onAfterRender:function(target){
			$.fn.datagrid.defaults.view.onAfterRender.call(this,target);
			var opts = $(target).datagrid('options');
			var vc = $(target).datagrid('getPanel').children('div.datagrid-view');
			vc.children('div.datagrid-empty').remove();
			if (!$(target).datagrid('getRows').length){
				var d = $('<div class="datagrid-empty"></div>').html(opts.emptyMsg || 'no records').appendTo(vc);
				d.css({
					position:'absolute',
					left:0,
					top:50,
					width:'100%',
					textAlign:'center'
				});
			}
		}
	});
	
	    $.fn.datebox.defaults.formatter = function(date){
		var y = date.getFullYear();
		var m = date.getMonth()+1;
		var d = date.getDate();
		return y+'-'+m+'-'+d;
	}  		
</script>	
</head>
<body class="easyui-layout" >
	<div region="center"><table id="grid"></table></div>

		<div id="tb" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
	 
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;项目编号: <input id="contractserial" class="easyui-textbox" style="width:100px">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;项目名称: <input id="cPName" class="easyui-textbox" style="width:100px">
		 
			<a href="#"  id="search" class="easyui-linkbutton" iconCls="icon-search">搜索</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 
		
		</div>
	</div>
	
	
 
</body>
</html>